//
//  LoginModel.m
//  RequestNET
//
//  Created by gavin on 14-8-12.
//  Copyright (c) 2014年 gavin.gu@live.com. All rights reserved.
//

#import "LoginModel.h"
#import "NETAPIClient.h"
#import "NSDictionary+JsonMethods.h"


@implementation LoginModel


+ (AFHTTPRequestOperation *)getTestModel:(NSDictionary *)paramDic
                               withBlock:(void (^)(LoginModel *login, NSError *error))block{

    
    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
    if (paramDic) {
        [parameters setObject:[paramDic jsonFromDictionary] forKey:@"jsonString"];
    }else{
        parameters = nil;
    }
    NSLog(@"%@",parameters);
    
    return [[NETAPIClient sharedClient] POST:@"" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSDictionary *result = responseObject;
        
        LoginModel *login =  [LoginModel objectFromDictionary:[result objectForKey:@"success"]];
        
        //是否为空的判断～
        
        block(login, nil);
        
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}


@end
